1 Imports System.Data.SqlClient
2 Imports Excel = Microsoft.Office.Interop.Excel
3
4 Public Class frmServiceDoneReport
5
6 Sub Reset()
7 dtpDateFrom.Text = Today
8 dtpDateTo.Text = Today
9 End Sub
10 Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
11 Reset()
12 End Sub
13
14
15 Private Sub btnClose_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
16 Me.Close()
17 End Sub
18
19 Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
20 Cursor = Cursors.Default
21 Timer1.Enabled = False
22 End Sub
23
24
25 Private Sub btnGetData_Click(sender As System.Object, e As System.EventArgs) Handles btnGetData.Click
26 Try
27 Cursor = Cursors.WaitCursor
28 Timer1.Enabled = True
29 Dim rpt As New rptService 'The report you created.
30 Dim myConnection As SqlConnection
31 Dim MyCommand, MyCommand1 As New SqlCommand()
32 Dim myDA, myDA1 As New SqlDataAdapter()
33 Dim myDS As New DataSet 'The DataSet you created.
34 myConnection = New SqlConnection(cs)
35 MyCommand.Connection = myConnection
36 MyCommand1.Connection = myConnection
37 MyCommand.CommandText = "SELECT * FROM Service INNER JOIN Customer ON Service.CustomerID = Customer.ID INNER JOIN InvoiceInfo1 ON Service.S_ID = InvoiceInfo1.ServiceID INNER JOIN Invoice1_Product ON InvoiceInfo1.Inv_ID = Invoice1_Product.InvoiceID where InvoiceInfo1.InvoiceDate between @d1 and @d2 order by invoiceDate"
38 MyCommand.Parameters.Add("@d1", SqlDbType.DateTime, 30, "Date").Value = dtpDateFrom.Value.Date
39 MyCommand.Parameters.Add("@d2", SqlDbType.DateTime, 30, "Date").Value = dtpDateTo.Value.Date
40 MyCommand1.CommandText = "SELECT * from Company"
41 MyCommand.CommandType = CommandType.Text
42 MyCommand1.CommandType = CommandType.Text
43 myDA.SelectCommand = MyCommand
44 myDA1.SelectCommand = MyCommand1
45 myDA.Fill(myDS, "InvoiceInfo1")
46 myDA.Fill(myDS, "Invoice1_Product")
47 myDA.Fill(myDS, "Service")
48 myDA.Fill(myDS, "Customer")
49 myDA1.Fill(myDS, "Company")
50 rpt.SetDataSource(myDS)
51 rpt.SetParameterValue("p1", dtpDateFrom.Value.Date)
52 rpt.SetParameterValue("p2", dtpDateTo.Value.Date)
53 rpt.SetParameterValue("p3", Today)
54 frmReport.CrystalReportViewer1.ReportSource = rpt
55 frmReport.ShowDialog()
56 Catch ex As Exception
57 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
58 End Try
59 End Sub
60
61 Private Sub frmServiceDoneReport_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
62
63 End Sub
64 End Class